package com.fr.report.parameter;

import com.fr.base.FRContext;
import com.fr.base.XMLable;
import com.fr.base.core.FRCoreContext;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ClassParameterProcessor extends AbstractParameterProcessor
  implements XMLable
{
  private String className;
  private transient ParameterProcessor _pp = null;

  public ClassParameterProcessor()
  {
  }

  public ClassParameterProcessor(String paramString)
  {
    setClassName(paramString);
  }

  public String getClassName()
  {
    return this.className;
  }

  public void setClassName(String paramString)
  {
    this.className = paramString;
  }

  private ParameterProcessor createParameterProcessor()
  {
    if (this._pp == null)
      try
      {
        this._pp = ((ParameterProcessor)FRCoreContext.classForName(getClassName()).newInstance());
      }
      catch (Exception localException)
      {
        FRContext.getLogger().log(Level.WARNING, "ClassName: " + getClassName());
        FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
        this._pp = new AbstractParameterProcessor(this)
        {
          private final ClassParameterProcessor this$0;
        };
      }
    return this._pp;
  }

  public Map process(Map paramMap)
  {
    return createParameterProcessor().process(paramMap);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("ClassPPAttr")))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("className")) != null)
        setClassName(str);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("ClassPPAttr").attr("className", getClassName()).end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return new ClassParameterProcessor(this.className);
  }
}